
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';

class FlutterPluginDemo {
  static const MethodChannel _channel =
      const MethodChannel('flutter_plugin_demo');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<dynamic> get test async {
    Map<String, dynamic> args = <String, dynamic>{"key1":"value1","key2":"value2"};
    dynamic res = await _channel.invokeMethod('test',args);

    return res;
  }


  static initEventChannel(ValueChanged<String> valueCallback) {
    _channel.setMethodCallHandler((call) async {
      if (call.method == "flutter_plugin_demo_msg_from_native") {
        Map res = Map<String, dynamic>.from(call.arguments);
        valueCallback(res.toString());

      }
      return null;
    });
  }

}
